package com.example.as_sum.activity;

import android.graphics.Color;
import android.support.design.widget.Snackbar;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.example.as_sum.R;

import javax.net.SocketFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;

/**
 * Snackbar支持自定义布局
 * SnackbarUtil工具类
 */
public class SnackbarActivity extends RootActivity {

    private View mView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mView=getLayoutInflater().inflate(R.layout.activity_snackbar,null);
        setContentView(mView);
        initTitle("Snackbar测试");
    }
    public void showDefult(View view){
        Snackbar snackbar=Snackbar.make(mView,"Hello Snackbar",Snackbar.LENGTH_LONG);
        snackbar.show();
    }
    public void showBtn(final View view){
        Snackbar snackbar=Snackbar.make(mView,"你确定要提交吗？",Snackbar.LENGTH_LONG);
        snackbar.setAction("提交", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Snackbar.make(mView,"提交成功！！",Snackbar.LENGTH_LONG).show();
            }
        });
        snackbar.setCallback(new Snackbar.Callback() {
            @Override
            public void onDismissed(Snackbar snackbar, int event) {
                super.onDismissed(snackbar, event);
                Toast.makeText(SnackbarActivity.this,"你单机了提交",Toast.LENGTH_LONG).show();
            }

            @Override
            public void onShown(Snackbar snackbar) {
                super.onShown(snackbar);
            }
        });
        snackbar.show();
    }
    public void showBtn2(View view){
        Snackbar snackbar=Snackbar.make(mView, "你确定要提交吗？", Snackbar.LENGTH_LONG);
        snackbar.setAction("提交", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Snackbar.make(mView,"提交成功！！",Snackbar.LENGTH_LONG).show();
            }
        });
        snackbar.setActionTextColor(Color.RED);
        View sbView = snackbar.getView();
        sbView.setBackgroundColor(Color.GRAY);//修改view的背景色
        TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
        textView.setTextColor(Color.YELLOW);

        snackbar.setCallback(new Snackbar.Callback() {
            @Override
            public void onDismissed(Snackbar snackbar, int event) {
                super.onDismissed(snackbar, event);
                Toast.makeText(SnackbarActivity.this, "你单机了提交", Toast.LENGTH_LONG).show();
            }

            @Override
            public void onShown(Snackbar snackbar) {
                super.onShown(snackbar);
            }
        });
        snackbar.show();
    }
}
